package exercise.exer4;

class Circle extends GeometricObject{
    private double radius;

    public Circle() {
        color = "white";
        weight = 1.0;
        radius = 1.0;
    }

    public Circle(double radius) {
        color = "white";
        weight = 1.0;
        this.radius = radius;
    }

    public Circle(String color, double weight, double radius) {
        super(color, weight);
        this.radius = radius;
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    public double findArea(){
        return 3.14 * radius * radius;
    }

    //重写equals
    public boolean equals(Object object){
        if(this == object) {
            return true;
        }
        if(object instanceof Circle){
            Circle c = (Circle)object;
            return this.radius == c.radius;
        }
        return false;
    }

    //重写toString
    public String toString(){
        return "Circle[radius = " + radius +"]";
    }
}